package magics
{
	import flash.display.BitmapData;
	import flash.display.MovieClip;

	public class MagicCache
	{
		public function MagicCache()
		{
			_mcCache = [];
			_bmdCache = [];
		}
		
		public static function get instance():MagicCache
		{
			if(_instance == null)
				_instance = new MagicCache();
			return _instance;
		}
		
		public function setMagic(name:String,type:String,magic:Object):void
		{
			if(type == "mc")
			{
				var m:MovieClip = magic as MovieClip;
				m.gotoAndStop(1);
				_mcCache[name] = m;
				
			}
			else if(type == "bmd")
			{
				var bmd:Vector.<BitmapData> = magic as Vector.<BitmapData>;
				_bmdCache[name] = bmd;
			}
		}
		
		public function getMCMagic(name:String):MovieClip
		{
			return _mcCache[name];
		}
		
		public function getBMDMagic(name:String):Vector.<BitmapData>
		{
			return _bmdCache[name];
		}
		
		private var _mcCache:Array;
		private var _bmdCache:Array;
		private static var _instance:MagicCache;
	}
}